
#import "AlertPopViewController.h"

@interface AlertPopViewController ()<UITextFieldDelegate>

@end

@implementation AlertPopViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    switch (self.type) {
        case AlertPopViewControllerTypeCancel:
            self.enterRight.active = YES;
            self.enterCenter.active = NO;
            self.enter.hidden = NO;
            self.cancel.hidden = NO;
            self.input.hidden = YES;
            break;
        case AlertPopViewControllerTypeOnlyOK:
            self.enterRight.active = NO;
            self.enterCenter.active = YES;
            self.enter.hidden = NO;
            self.cancel.hidden = YES;
            self.input.hidden = YES;
            break;
        case AlertPopViewControllerTypeInput:
            self.enterRight.active = YES;
            self.enterCenter.active = NO;
            self.enter.hidden = NO;
            self.cancel.hidden = NO;
            self.content.hidden = YES;
            self.input.hidden = NO;
            self.btnTop.constant = 44;
            break;
    }
}

- (IBAction)actionForBtn:(UIButton *)sender {
    [self dismissViewControllerAnimated:NO completion:nil];
    if (sender.tag != 201) {
        if (self.block) {
            self.block((int)sender.tag, self.type == AlertPopViewControllerTypeInput ? self.input.text : @"");
        }
    }
}
+(void)pop:(NSString *)title content:(NSString*)content type:(AlertPopViewControllerType) type block:(void(^)(int tag,NSString *text))block{
    AlertPopViewController * vc = [AlertPopViewController new];
    vc.type = type;
    vc.titleLbl.text = LS(title);
    vc.content.text = LS(content);
    vc.content.textAlignment = NSTextAlignmentCenter;
    vc.block = block;
    [[vc currentVC] presentViewController:vc animated:YES completion:nil];
}
#pragma mark - UITextFieldDelegate
@end
